import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StudentLeaveVO, StudentLeaveForm, StudentLeaveQuery } from '@/api/attendance/leave/student/types';

/**
 * 查询学生请假列表
 * @param query
 * @returns {*}
 */

export const listStudentLeave = (query?: StudentLeaveQuery): AxiosPromise<StudentLeaveVO[]> => {
  return request({
    url: '/attendance/leave/student/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询学生请假详细
 * @param id
 */
export const getStudentLeave = (id: string | number): AxiosPromise<StudentLeaveVO> => {
  return request({
    url: '/attendance/leave/student/' + id,
    method: 'get'
  });
};

/**
 * 新增学生请假
 * @param data
 */
export const addStudentLeave = (data: StudentLeaveForm) => {
  return request({
    url: '/attendance/leave/student',
    method: 'post',
    data: data
  });
};

/**
 * 修改学生请假
 * @param data
 */
export const updateStudentLeave = (data: StudentLeaveForm) => {
  return request({
    url: '/attendance/leave/student',
    method: 'put',
    data: data
  });
};

/**
 * 删除学生请假
 * @param id
 */
export const delStudentLeave = (id: string | number | Array<string | number>) => {
  return request({
    url: '/attendance/leave/student/' + id,
    method: 'delete'
  });
};
